package com.sgb.kjwl.view.ui.adapter.self;

import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.bumptech.glide.request.RequestOptions;
import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.TeamAuthListEntity;
import com.sgb.kjwl.view.widget.manage.StatusView;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

/***
 * 团队列表
 */
public class TeamAuthListAdapter extends BaseRecycleAdapter<TeamAuthListEntity> {

    private StatusView tvStatus;
    private TextView namePhone;

    public TeamAuthListAdapter(Context context, List<TeamAuthListEntity> datas) {
        super(context, R.layout.item_team_auth_list, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, final TeamAuthListEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        tvStatus = holder.getItem().findViewById(R.id.tv_status);
        namePhone = holder.getItem().findViewById(R.id.name_phone);
        ImageView logo = holder.getItem().findViewById(R.id.img);
        RequestOptions optionsTeam = new RequestOptions()
                .placeholder(R.drawable.icon_team_default)//图片加载出来前，显示的图片
                .fallback(R.drawable.icon_team_default) //url为空的时候,显示的图片
                .apply(RequestOptions.bitmapTransform(new CircleCrop()))//裁剪圆形
                .error(R.drawable.icon_team_default);//图片加载失败后，显示的图片
        Glide.with(context).load(entity.getLogo()).apply(optionsTeam).into(logo);
        switch (entity.getTeamAuthStatus()){
            case 1:
                tvStatus.setText("审核中");
                tvStatus.setBgColor(R.color.color_secondary_blue);
                namePhone.setText(entity.getContact()+"        "+entity.getPhone());
                break;
            case 2:
                tvStatus.setText("已认证");
                tvStatus.setBgColor(R.color.color_secondary_green);
                namePhone.setText(entity.getContact()+"        "+entity.getPhone());
                break;
            case 3:
                tvStatus.setText("认证失败");
                tvStatus.setBgColor(R.color.a_color_ff2928);
                namePhone.setText(entity.getContact()+"        "+entity.getPhone());
                break;
        }


    }
}
